﻿using System.Numerics;

namespace PiCompressor
{
    public sealed class PiCompressor<T>
    {
        public IPiCalculator<T> PiCalculator { get; }
        public PiCompressor(IPiCalculator<T> calculator)
        {
            PiCalculator = calculator;
        }

        public async ValueTask<T> DecompressAsync(BigInteger compressedValue)
        {
            return await PiCalculator.CalculatePiAsync(compressedValue);
        }

        public async ValueTask<BigInteger?> CompressAsync(T value)
        {
            return await PiCalculator.MeasureLengthAsync(value);
        }
    }
}